
<template>
  <div class="voice-box">
    <audio controls>
      <source :src="url">
      Your browser does not support the audio element.
    </audio>
  </div>
</template>
<script>

export default {
  name: 'BaseVoice',
  props: {
    url: {
      required: true,
      type: String,
      default: ''
    }
  },
  data() {
    return {
      sliderTime: 0,
      audio: {
        // 该字段是音频是否处于播放状态的属性
        playing: false,
        // 音频当前播放时长
        currentTime: 0,
        // 音频最大播放时长
        maxTime: 0,
        minTime: 0,
        step: 0.1
      }
    }
  },
  methods: {

    // 播放音频
    play() {
      this.$refs.audio.play()
    },
    // 暂停音频
    pause() {
      this.$refs.audio.pause()
    }
  }
}
</script>
<style lang="scss">
.voice-box {
  padding: 0 20px;
  .play-btn {
    width: 28px;
    height: 30px;
    // background: url("../../assets/images/listen/play.png") no-repeat center -3px;
    background-size: 100% 100%;
    margin-right: 20px;
    &.btn-pause {
      // background: url("../../assets/images/listen/pause.png") no-repeat center -2px;
      background-size: 100% 100%;
    }
  }
  .time {
    font-size: 20px;
  }
  .slider-box {
    display: inline-block;
    margin: 0 30px;
  }
  .slider {
    width: 360px;
    position: relative;
    top: -5px;
    height: 24px;
    display: flex;
    align-items: center;
    cursor: default;
    user-select: none;
    outline: none;
  }

  .slider-track {
    position: absolute;
    height: 20px;
    left: 0;
    right: 0;
    top: 50%;
    margin-top: -1px;
    background-color: rgba(255, 255, 255, 0.3);
  }

  .slider-fill {
    position: absolute;
    width: 20px;
    height: 19px;
    background-color: #fff;
    left: 0;
    top: 50%;
    margin-top: -1px;
  }

  .slider-thumb {
    position: absolute;
    top: 85%;
    width: 20px;
    height: 21px;
    background-color: #fff;
    color: #fff;
    // border-radius: 50%;
    transform: translate(-50%, -50%);
    cursor: pointer;
  }
}
</style>
